package com.study.compose.beta.view

import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.aspectRatio
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.GridCells
import androidx.compose.foundation.lazy.LazyVerticalGrid
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.unit.dp
import com.module.compose.base.composable.imageLoader.rememberCoilPainter
import com.study.compose.beta.utils.rememberRandomSampleImageUrl

/**
 * 作者：zhangjunfei 2021/6/18 9:28 上午
 * 主页：https://gitee.com/ZhangQQ_123/projects
 * 描述：grid列表
 */

@OptIn(
    ExperimentalStdlibApi::class,
    ExperimentalFoundationApi::class
)
@Composable
fun GridSample() {

    LazyVerticalGrid(
        cells = GridCells.Adaptive(120.dp),
        contentPadding = PaddingValues(10.dp)
    ) {
        items(60) {
            Image(
                painter = rememberCoilPainter(
                    request = rememberRandomSampleImageUrl(),
                    fadeIn = true
                ),
                contentDescription = null,
                modifier = Modifier
                    .aspectRatio(1f)
                    .padding(10.dp)
                    .fillMaxWidth()
                    .clip(shape = RoundedCornerShape(5.dp))
            )
        }
    }
}